# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 获取浏览器驱动对象
driver = webdriver.Firefox()
# 打开测试页面
url = 'file:///root/NSD2408/html/registerA.html'
driver.get(url)
# 通过XPATH定位用户名
# / 绝对路径
# username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p/input')
# 结合元素的属性
# username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[@id="p1"]/input')
# // 相对路径
# * 任意元素
username = driver.find_element(By.XPATH, '//*[@id="userA"]')
username.send_keys('admin')
# 如果查找第n个元素，通过下标，从1开始
password = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[2]/input')
password.send_keys('123456')




# 停顿3秒，关闭浏览器驱动
sleep(3)
driver.quit()